package lk.service.blogspringboot.service.impl;

import lk.service.blogspringboot.domain.ArticleAudit;
import lk.service.blogspringboot.mapper.ArticleAuditMapper;
import lk.service.blogspringboot.service.ArticleAuditService;
import lk.service.blogspringboot.util.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 文章审核表(ArticleAudit)表服务实现类
 *
 * @author LK
 * @since 2024-08-22 10:33:36
 */
@Service("articleAuditService")
public class ArticleAuditServiceImpl implements ArticleAuditService {
    @Resource
    private ArticleAuditMapper articleAuditMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param auditId 主键
     * @return 实例对象
     */
    @Override
    public R queryById(Integer auditId) {
        return R.ok().setData(this.articleAuditMapper.queryById(auditId));
    }

    /**
     * 全查询
     *
     * @param articleAudit 筛选条件
     * @return 查询结果
     */
    @Override
    public R queryAll(ArticleAudit articleAudit) {
        return R.ok().setData(this.articleAuditMapper.queryAll(articleAudit));
    }

    /**
     * 新增数据
     *
     * @param articleAudit 实例对象
     * @return 实例对象
     */
    @Override
    public R insert(ArticleAudit articleAudit) {
        this.articleAuditMapper.insert(articleAudit);
        return R.ok().setData(articleAudit);
    }

    /**
     * 修改数据
     *
     * @param articleAudit 实例对象
     * @return 实例对象
     */
    @Override
    public R update(ArticleAudit articleAudit) {
        this.articleAuditMapper.update(articleAudit);
        return R.ok().setData(this.queryById(articleAudit.getAuditId()));
    }

    /**
     * 通过主键删除数据
     *
     * @param auditId 主键
     * @return 是否成功
     */
    @Override
    public R deleteById(Integer auditId) {
        boolean del = this.articleAuditMapper.deleteById(auditId) > 0;
        return R.ok().setData(del);
    }
}

